package com.tencent.sr.iris.basic.saas.service.util;

import com.tencent.sr.iris.basic.saas.common.enums.AssessmentThresholdTypeEnum;
import com.tencent.sr.iris.basic.saas.common.enums.IrisTaskTypeEnum;
import com.tencent.sr.iris.basic.saas.service.model.operate.*;

/**
 * 运营团长任务工具类
 *
 * @author nixiaolin
 * @date 2023/2/8 11:39
 */
public abstract class OperateBoardUtils {


    /**
     * 创建GMV冲刺赛/销量冲刺赛导出实体
     *
     * @param taskTargetEvaluation
     * @param taskPhaseRuleAssessmentThresholdType
     * @return
     */
    public static OperateBoardSprintExportInfo newOperateBoardSprintExportInfo(Integer taskTargetEvaluation, Integer taskPhaseRuleAssessmentThresholdType) {
        Class<? extends OperateBoardSprintExportInfo> exportClass = getExportClass(taskTargetEvaluation, taskPhaseRuleAssessmentThresholdType);
        try {
            return exportClass.newInstance();
        } catch (Exception e) {
            return new OperateBoardSprintExportInfo();
        }
    }

    /**
     * 创建GMV冲刺赛/销量冲刺赛导出XClass对象
     *
     * @param taskTargetEvaluation
     * @param taskPhaseRuleAssessmentThresholdType
     * @return
     */
    public static Class<? extends OperateBoardSprintExportInfo> getExportClass(Integer taskTargetEvaluation, Integer taskPhaseRuleAssessmentThresholdType) {
        AssessmentThresholdTypeEnum typeEnum = AssessmentThresholdTypeEnum.getEnumByCode(taskPhaseRuleAssessmentThresholdType);
        if (typeEnum == null) {
            IrisTaskTypeEnum taskTypeEnum = IrisTaskTypeEnum.getEnumByType(taskTargetEvaluation);
            if (taskTypeEnum == null) {
                return OperateBoardSalesSprintExportInfo.class;
            }

            switch (taskTypeEnum) {
                case GMV_SPRINT:
                case GMV_SPRINT_MAGNIFY:
                    return OperateBoardGmvSprintExportInfo.class;
                case SALE_SPRINT:
                case NEW_SALE_SPRINT:
                    return OperateBoardSaleNumSprintExportInfo.class;
                default:
                    return OperateBoardSalesSprintExportInfo.class;
            }
        }

        switch (typeEnum) {
            case SALE_NUM:
                return OperateBoardSalesSprintExportInfo.class;
            case DISTRIBUTION_ORDER_NUM:
                return OperateBoardDistributionSprintExportInfo.class;
            default:
                return OperateBoardSprintExportInfo.class;
        }

    }
}
